package cn.iocoder.yudao.module.nmkj.controller.app.video;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.nmkj.controller.admin.video.vo.VideoPageReqVO;
import cn.iocoder.yudao.module.nmkj.controller.admin.video.vo.VideoRespVO;
import cn.iocoder.yudao.module.nmkj.dal.dataobject.video.VideoDO;
import cn.iocoder.yudao.module.nmkj.service.video.VideoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户APP - 展示视频")
@RestController
@RequestMapping("/nmkj/video")
@Validated
public class AppVideoController {

    @Resource
    private VideoService videoService;

    @GetMapping("/page")
    @Operation(summary = "获得展示视频分页")
    public CommonResult<PageResult<VideoRespVO>> getVideoPage(@Valid VideoPageReqVO pageReqVO) {
        pageReqVO.setStatus(1); //用户端请求的数据必须为启用状态
        PageResult<VideoDO> pageResult = videoService.getVideoPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, VideoRespVO.class));
    }

}
